home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / boot / czesc_2 / toolmanager / source / prefs / window.c < prev   
C/C++ Source or Header  |  1993-05-15  |  3KB  |  112 lines

  1. /*
  2.  * window.c  V2.1
  3.  *
  4.  * safe window close function
  5.  *
  6.  * (c) 1990-1993 Stefan Becker
  7.  */
  8.  
  9. #include "ToolManagerConf.h"
  10.  
  11. /* Wait pointer image data */
  12. __chip static const UWORD WaitPointer[]={
  13.                                          0x0000, 0x0000,
  14.  
  15.                                          0x0400, 0x07c0,
  16.                                          0x0000, 0x07c0,
  17.                                          0x0100, 0x0380,
  18.                                          0x0000, 0x07e0,
  19.                                          0x07c0, 0x1ff8,
  20.                                          0x1ff0, 0x3fec,
  21.                                          0x3ff8, 0x7fde,
  22.                                          0x3ff8, 0x7fbe,
  23.                                          0x7ffc, 0xff7f,
  24.                                          0x7efc, 0xffff,
  25.                                          0x7ffc, 0xffff,
  26.                                          0x3ff8, 0x7ffe,
  27.                                          0x3ff8, 0x7ffe,
  28.                                          0x1ff0, 0x3ffc,
  29.                                          0x07c0, 0x1ff8,
  30.                                          0x0000, 0x07e0,
  31.  
  32.                                          0x0000, 0x0000
  33.                                         };
  34.  
  35. /* Close a window safely */
  36. void CloseWindowSafely(struct Window *w)
  37. {
  38.  struct IntuiMessage *msg;
  39.  
  40.  DEBUG_PRINTF("CloseWindowSafely: 0x%08lx\n",w);
  41.  
  42.  /* we forbid here to keep out of race conditions with Intuition */
  43.  Forbid();
  44.  
  45.  /* Remove all messsages for this window */
  46.  msg=GetHead(&w->UserPort->mp_MsgList);
  47.  while (msg)
  48.   /* Does this message point to the window? */
  49.   if (msg->IDCMPWindow==w) {
  50.    struct IntuiMessage *nextmsg=GetSucc(msg);
  51.  
  52.    /* Yes. Remove it from port */
  53.    Remove((struct Node *) msg);
  54.  
  55.    /* Reply it */
  56.    ReplyMsg((struct Message *) msg);
  57.  
  58.    /* Get pointer to next message */
  59.    msg=nextmsg;
  60.   }
  61.    /* No. Get pointer to next message */
  62.   else msg=GetSucc(msg);
  63.  
  64.  /* clear UserPort so Intuition will not free it */
  65.  w->UserPort=NULL;
  66.  
  67.  /* tell Intuition to stop sending more messages */
  68.  ModifyIDCMP(w,0);
  69.  
  70.  /* turn multitasking back on */
  71.  Permit();
  72.  
  73.  DEBUG_PRINTF("Closing window\n");
  74.  
  75.  /* and really close the window */
  76.  CloseWindow(w);
  77.  
  78.  DEBUG_PRINTF("Window closed\n");
  79. }
  80.  
  81. /* Disable a window */
  82. void DisableWindow(struct Window *w, struct Requester *req)
  83. {
  84.  /* Disable IDCMP */
  85.  ModifyIDCMP(w,IDCMP_REFRESHWINDOW);
  86.  
  87.  /* Block window input */
  88.  Request(req,w);
  89.  
  90.  /* Set wait pointer */
  91.  if (OSV39)
  92.   SetWindowPointer(w,WA_BusyPointer,TRUE,TAG_DONE);
  93.  else
  94.   SetPointer(w,WaitPointer,16,16,-6,0);
  95. }
  96.  
  97. /* Enable a window */
  98. void EnableWindow(struct Window *w, struct Requester *req, ULONG idcmp)
  99. {
  100.  /* Clear wait pointer */
  101.  if (OSV39)
  102.   SetWindowPointer(w,TAG_DONE);
  103.  else
  104.   ClearPointer(w);
  105.  
  106.  /* Enable window input */
  107.  EndRequest(req,w);
  108.  
  109.  /* Enable IDCMP */
  110.  ModifyIDCMP(w,idcmp);
  111. }
  112.